<!--
 * @Author: HeAo
 * @Date: 2021-10-12 15:26:52
 * @LastEditTime: 2021-10-12 15:34:59
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \web2103-2105\web2103code\3-2-Vue\day04\5-混入.html
 * 别乱动！
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    {{attr}}-{{msg}}-{{obj}}
  </div>
  <script>
    let mixin = {
      data() {
        return {
          msg: '我是mixin数据',
          obj: {
            name: 'zhangsan'
          }
        }
      },
      methods: {
        foo() {
          console.log('this is mixin fun');
        }
      },
      created() {
        console.log('this is mixin created');
      }
    }



    let vm = new Vue({
      el: '#app',
      data: {
        attr: '我是vue根实例数据',
        obj: {
          age: 12
        }
      },
      methods: {
        foo() {
          console.log('this is vue fun');
        }
      },
      created() {
        console.log('this is vue created');
      },
      mixins: [mixin]
    })
  </script>
</body>

</html>